﻿using BW.MesProject.Public.ErrorCode;
using BW.MesProject.WareHouse.Application;
using BW.MesProject.WareHouse.Domain;
using BW.MesProject.WareHouse.Infrastructure;
using BW.MesProject.WareHouse.Infrastructure.Dto.Input;
using BW.MesProject.WareHouse.Infrastructure.Dto.OutPut;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.WareHouse.Host.Controllers
{
    /// <summary>
    /// 货架库区
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ShelvesController : ControllerBase
    {
        // GET: api/<ShelvesController>
        private readonly IShelvesServices ShelvesServices;

        public ShelvesController(IShelvesServices ShelvesServices)
        {
            this.ShelvesServices = ShelvesServices;
        }
        /// <summary>
        /// 添加货位/库区
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddShelves(ShelvesModel model)
        {
            return ShelvesServices.AddShelves(model);
        }
        /// <summary>
        /// 删除货位/库区
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DeleteShelves(long Id)
        {
            return ShelvesServices.DeleteShelves(Id);
        }
        /// <summary>
        /// 获取货位/库区
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<ShelvesOut>> GetShelves([FromQuery] QryInput qryInput)
        {
            return ShelvesServices.GetShelves(qryInput);
        }
        /// <summary>
        /// 修改货位/库区
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateShelves(ShelvesModel model)
        {
            return ShelvesServices.UpdateShelves(model);
        }

        /// <summary>
        /// 修改启用
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateEnable(ShelvesModel model)
        {
            return ShelvesServices.UpdateEnable(model);
        }

        /// <summary>
        /// 软删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> UpdateDelete(long Id)
        {
            return ShelvesServices.UpdateDelete(Id);
        }

        /// <summary>
        /// 查询编码
        /// </summary>
        /// <param name="ShelvesID"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<int> GetShelvesID(string ShelvesID)
        {
            return ShelvesServices.GetShelvesID(ShelvesID);
        }
    }
}
